package org.lanplay.server.pages;

import org.apache.wicket.Session;
import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.lanplay.server.LanPlaySession;
import org.lanplay.server.dao.UserDao;
import org.lanplay.server.model.User;

import com.google.inject.Inject;

@AuthorizeInstantiation("USER")
public class WelcomePage extends TransactionAwarePage {
	private static final long serialVersionUID = 1L;

	@Inject
	private UserDao dao;

	public WelcomePage() {
		User user = dao.getById((Long) Session.get().getAttribute(
				LanPlaySession.USER_ATTRIBUTE));

		String name = user.getName() == null ? "Unknown" : user.getName();
		add(new Label("message", "Hello " + name + "@" + user.getKey()
				+ ", userlist: " + dao.getUserList().toString()));

		add(new BookmarkablePageLink<SimpleGamesListPage>("linkToGames",
				SimpleGamesListPage.class));
		add(new BookmarkablePageLink<UserProfilePage>("profilePage",
				UserProfilePage.class));
		add(new BookmarkablePageLink<MatchRequestsPage>("matchRequests",
				MatchRequestsPage.class));
	}
}
